package io;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.ObjectInputStream;

import model.IState;

public class Load {
	
	public IState readFromFile(String file) throws ClassNotFoundException{

		ObjectInputStream inputStream = null;
		Object content = null;

		try{
			//Construct the LineNumberReader object
			inputStream = new ObjectInputStream(new FileInputStream(file));
			//Read the object
			content = inputStream.readObject();

		} catch (FileNotFoundException ex){
			ex.printStackTrace();
		} catch (IOException ex){
			ex.printStackTrace();
		} finally {
			try{
				if(inputStream != null){
					inputStream.close();
				}
			} catch (IOException ex){
				ex.printStackTrace();
			}
		}

		IState arr = (IState) content;
		
		return arr;
	} //ReadFromFile
}
